package com.fanjun.learning.multithread.Two_Phase_Termination;

/**
 * 两阶段中断线程
 */
public class Main {
    public static void main(String[] args) {
        System.out.println("main: begin");
        try {
//            CountThread t = new CountThread();
//            t.start();
//
//            Thread.sleep(10000);
//            System.out.println("main: shutdownrequest");
////            t.shutdownRequest();
//
//            System.out.println("main: join");
////            t.join();
//            // 直接调用stop方法,不会抛出InteruttedException,而是直接退出
//            t.stop();
//            System.out.println("线程是否还活着:" + t.isAlive());
            CountThreadSec t1 = new CountThreadSec("Thread-1");
            CountThreadSec t2 = new CountThreadSec("Thread-2");
            CountThreadSec t3 = new CountThreadSec("Thread-3");
            t1.start();
            t2.start();
            t3.start();
            t1.interrupt();
            t2.interrupt();
            t3.interrupt();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("main: end");
    }
}
